package com.autoplaza;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.Window;

public class FragmentGallery extends FragmentActivity {
	private MyAdapter mAdapter;
	private ViewPager mPager;
	public static String[] arrayURL;
	public static Context ctx;
	
	

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.ui_informacioneventofotos);
		
		ctx = getApplicationContext();
		
		Bundle extras = getIntent().getExtras();
		if (extras!=null){
			arrayURL=extras.getStringArray("fotos");
		}
		
		mAdapter = new MyAdapter(getSupportFragmentManager());

		mPager = (ViewPager) findViewById(R.id.pager);
		mPager.setAdapter(mAdapter);
	}

	public static class MyAdapter extends FragmentPagerAdapter {
		public MyAdapter(FragmentManager fm) {
			super(fm);
		}

		@Override
		public int getCount() {
			return arrayURL.length;
		}

		@Override
		public Fragment getItem(int position) {
			

			return new ImageFragment(arrayURL[position],ctx, arrayURL.length, position);
//			switch (position) {
////			case 0:
////				return new DetailFragment();
////			case 1:
//				return new ImageFragment(R.drawable.ic_launcher);
//			case 2:
//				return new ImageFragment(R.drawable.thumb);
//
//			default:
//				return null;
//			}
		}
	}
}
